﻿define(['models/model.bottomlink'], function(BottomLinkModel) {
	var TopLink = {
		getDtoId : function(dto) {
			return dto.id;
		},
		fromDto : function(dto, item) {
			item = item || new BottomLinkModel();
			item.id(dto.id)
					.text(dto.text);
		  var children = [];
			if(dto.children){
				for (var i  = 0; i < dto.children.length; i ++){
					var child = this.fromDto(dto.children[i]);
					children.push(child);
				}
				item.children(children);
			}
			return item;
		}
	};
	return TopLink;
}); 